<template>
	<view>
		<image class="bg" src="../../static/uimage/sucai.jpg"></image>
		<view class="loginIn-page">
			<view class="iamage">
				<image src="../../static/uimage/car.svg"></image>
			</view>
			<view class="login">
				<view class="login-title">想去哪就去哪！</view>
				<view class="login-inp1">
					<input v-model="utel" placeholder-class="ps" placeholder="邮箱/手机号" />
				</view>
				<view class="login-inp2">
					<input placeholder-class="ps" placeholder="验证码" />
					<button><text>获取验证码</text></button>
				</view>
				<view class="login-inp3">
					<input v-model="upassword" placeholder-class="ps" password type="text"
						placeholder="密码为不低于八位的数字或字母组合" />
				</view>
				<view class="login-inp4">
					<input placeholder-class="ps" password type="text" placeholder="确认密码" />
				</view>
				<button class="login-register" @click="tochoose">开始注册</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				utel: '',
				upassword: ''
			}
		},
		methods: {
			//实现登录的方法
			tochoose() {
				uni.request({
					url: 'http://127.0.0.1:3000/regist',
					method: 'post',
					data: {
						utel: this.utel,
						upassword: this.upassword
					},
					success: (res) => {
						console.log(res.data)
						let result = res.data
						if (result.code === 1) {
							uni.showToast({
								title: '注册成功',
								icon: 'success'
							})
							//将用户id保存至本地缓存中
							uni.setStorageSync('_id', result._id)
							//跳转到主页面
							//navigateTo 不关闭当前页面，跳转到指定页面，可以返回
							//redirectTo 关闭当前页面跳转到指定页面
							//switchTab 关闭当前页面 跳转到TabBar页面
							uni.navigateTo({
								url: '/pages/uwork/choose'
							})
						} else if (result.code === 2) {
							uni.showToast({
								title: '注册失败',
								icon: 'error'
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
	.iamage {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 300rpx;
		height: 300rpx;
	}

	.bg {
		position: absolute;
		width: 100%;
		height: 100%;
	}

	.loginIn-page {
		position: absolute;
		width: 100%;
		height: 100%;
		background-color: rgba(255, 255, 255, 0);
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		align-items: center;
	}

	.login {
		width: 90%;
		height: 70%;
		background-color: rgba(255, 255, 200, 0);
		border-radius: 50rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.login-title {
		font-size: 40rpx;
		color: #FFCF4A;
		margin-top: 20rpx;
		margin-bottom: 60rpx;
	}

	.login-inp1 {
		display: flex;
		border: 4rpx solid black;
		padding: 20rpx;
		border-radius: 44rpx;
		width: 60%;
		margin-bottom: 30rpx;
		background-color: rgba(255, 255, 255, 0.95);
	}

	.login input {
		padding: 8rpx;
		font-size: 25rpx;
	}

	.login-inp1 input {
		flex: 1;
	}

	.login-inp2 input {
		flex: 1;
	}

	.login-inp3 input {
		flex: 1;
	}

	.login-inp4 input {
		flex: 1;
	}

	.login-inp2 {
		display: flex;
		border: 4rpx solid black;
		padding: 20rpx;
		border-radius: 44rpx;
		width: 60%;
		margin-bottom: 30rpx;
		background-color: rgba(255, 255, 255, 0.95);
	}

	.login-inp2 button {
		width: 38%;
		height: 40rpx;
		font-size: 20rpx;
		padding-bottom: 45rpx;
	}

	.login-inp3 {
		display: flex;
		border: 4rpx solid black;
		padding: 20rpx;
		border-radius: 44rpx;
		width: 60%;
		margin-bottom: 30rpx;
		background-color: rgba(255, 255, 255, 0.95);
	}

	.login-inp4 {
		display: flex;
		border: 4rpx solid black;
		padding: 20rpx;
		border-radius: 44rpx;
		width: 60%;
		margin-bottom: 30rpx;
		background-color: rgba(255, 255, 255, 0.95);
	}

	.login-confirm {
		margin-top: 50rpx;
		width: 70%;
		height: 88rpx;
		line-height: 88rpx;
		background-color: rgba(244, 206, 82, 0.95);
		color: white;
		border-radius: 44rpx;
	}

	.login-import {
		align-self: flex-end;
		margin-right: 120rpx;
		color: white;
		font-size: 25rpx;
	}

	.login-register {
		margin-top: 50rpx;
		width: 70%;
		height: 88rpx;
		line-height: 88rpx;
		background-color: rgba(244, 206, 82, 0.97);
		color: white;
		border-radius: 44rpx;
		font-size: 35rpx;
	}
</style>
